TWebBrowserEx XE6~XE7 FMX Win,OSx,iOS,Andriod
TWebBrowserEx class
This class provides a way for you to use in a unified manner WebBrowser in FireMonkey applications of Windows / OS X / iOS / Android.
Web Browser that was made using this class will use the web browser the default controls that are mounted on the platform as shown below.
| Platform | Component |
|---|---|
| Windows | IWebBrowser (IE) |
| OS X | WebView (Safari) |
| iOS | WebView |
| Android | WebView |
Operating environment
XE6, XE7 of Delphi / C ++ Builder / RAD Studio
If you move in XE5 previous
The change in the NSSTR StrToNSSTR
Remove Macapi.Helpers
Please change the.
File
I will download all the following files.
FMX.WebBrowser.Mac.pas OS X for WebBrowser class
FMX.WebBrowser.Win.pas Windows for WebBrowser class
Class that works in a unified manner WebBrowser FMX.WebBrowserEx.pas of multi-platform
Units that were transplanted into the definition of the Delphi WebView of Macapi.WebView.pas OS X
How to use
As described below, I will use in the same way as TWebBrowser of iOS / Android.
the uses FMX . WebBrowserEx ;
type
TForm1 = class ( TForm )
Panel1 : TPanel ;
Button1 : TButton ;
procedure FormCreate ( Sender : TObject ) ;
procedure Button1Click ( Sender : TObject ) ;
Private
FWebBrowser : TWebBrowserEx ;
end ;
procedure TForm1 . FormCreate ( Sender : TObject ) ;
begin
FWebBrowser : = TWebBrowserEx . Create ( Self ) ;
FWebBrowser . Parent : = Panel1 ;
FWebBrowser . Align : = TAlignLayout . Client ;
end ;
procedure TForm1 . Button1Click ( Sender : TObject ) ;
begin
FWebBrowser . URL : = 'Http://Www.Embarcadero.Com/' ;
// It is also possible to read a String like this
FWebBrowser . LoadFromStrings ( '
, '' ) ; end ;
In addition, as described below, I can also use JavaScript.
procedure TForm1 . Button2Click ( Sender : TObject ) ; var Value : String ; begin call by passing two arguments to the JavaScript function foo that is defined in the // HTML FWebBrowser . CallJS ( 'foo' , [ Param1 , Param2 ]) ;
// Is referred to as a standard way of TWebBrowser
FWebBrowser . EvaluteJavascript ( 'alert ("Delphi!")' ) ;
// To get the value of the tag in the HTML
if there is a tag that //
the attribute value of the id value of bar in this // ↓ it is possible to acquire
Value : = FWebBrowser . GetTagValue ( 'Bar' , 'value' ) ;
end ;
